package com.hl.card.modular.packBack.controller;

import com.hl.card.common.controller.BaseController;
import com.hl.card.common.remote.creditCard.CreditCardOrder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.hl.card.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.hl.card.modular.packBack.service.CreditCardOrderService;
/**
 * 信用卡管理控制器
 *
 * @author fengshuonan
 * @Date 2018-11-23 17:08:14
 */
@Controller
@RequestMapping("/creditCardOrder")
public class CreditCardOrderController extends BaseController {
    private String PREFIX = "/packback/creditCardOrder/";
    @Autowired
    private CreditCardOrderService creditCardOrderService;
    /**
     * 跳转到信用卡管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "creditCardOrder.html";
    }

    /**
     * 跳转到添加信用卡管理
     */
    @RequestMapping("/creditCardOrder_add")
    public String creditCardOrderAdd() {
        return PREFIX + "creditCardOrder_add.html";
    }
    /**
     * 跳转到修改信用卡管理
     */
    @RequestMapping("/creditCardOrder_update/{creditCardOrderId}")
    public String creditCardOrderUpdate(@PathVariable Integer creditCardOrderId, Model model) {
        CreditCardOrder creditCardOrder = creditCardOrderService.selectById(creditCardOrderId);
        model.addAttribute("item",creditCardOrder);
        LogObjectHolder.me().set(creditCardOrder);
        return PREFIX + "creditCardOrder_edit.html";
    }
    /**
     * 获取信用卡管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
//        return creditCardOrderService.selectList(null);
        return  creditCardOrderService.selectRemoteList(condition);
    }
    /**
     * 新增信用卡管理
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(CreditCardOrder creditCardOrder) {
        creditCardOrderService.insert(creditCardOrder);
        return SUCCESS_TIP;
    }
    /**
     * 删除信用卡管理
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer creditCardOrderId) {
        creditCardOrderService.deleteById(creditCardOrderId);
        return SUCCESS_TIP;
    }
    /**
     * 修改信用卡管理
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(CreditCardOrder creditCardOrder) {
        creditCardOrderService.updateById(creditCardOrder);
        return SUCCESS_TIP;
    }
    /**
     * 信用卡管理详情
     */
    @RequestMapping(value = "/detail/{creditCardOrderId}")
    @ResponseBody
    public Object detail(@PathVariable("creditCardOrderId") Integer creditCardOrderId) {
        return creditCardOrderService.selectById(creditCardOrderId);
    }
}
